<template>
	<view class="detail">
			<tui-list-view :title="title">
				<!-- <tui-list-cell>
					<tui-row>
						<tui-col :span="24">
							<input class="detailInput" type="text" placeholder="请输入残疾人名称" v-model="disabledName" />
						</tui-col>
					</tui-row>
				</tui-list-cell> -->
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">残疾人名称</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.disabledName||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">企业名称</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.enterpriseName||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">创建时间</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.createdTime|filterDate(11)}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">业务描述</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.businessContent||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">文件地址</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								<text @click="previewPdf(info)" style="color: #045efd;text-decoration: underline;">{{info.pdfUrlsName||'--'}}</text>
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<!-- <tui-list-cell>
					<tui-row>
						<tui-col :span="8">图片</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								<image style="width: 160rpx;" :src="info.imgUrls" @click="previewImg(info.imgUrls)" mode="widthFix"></image>
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell> -->
				<tui-list-cell v-show="info.confirmationStatus == 0">
					<tui-row>
						<tui-col :span="24">
							<view class="detailBtn" @click="workSubmit()">确认签约</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
			</tui-list-view>
	</view>
</template>

<script>
	const util = require("@/utils/util.js")
	const app = getApp()
	export default {
		data() {
			return {
				info: {},
				id: "",
				type: "",
				title: "工作确认详情",

				disabledName: "",
			}
		},
		onLoad(option) {
			if (option.id) {
				this.id = option.id;
				this.getDetail();
			}
		},
		filters: {
			// 日期文字处理
			filterDate(value, num) {
				if (!value) return '--'
				if (value.length > num) {
					return value.slice(0, num)
				}
				return value
			},
		},
		methods: {
			// 查看信息
			getDetail() {
				util.request('disabled/detailDisabledJobConfirmation', {
					id: this.id,
				}, "POST").then(res => {
					if (res.code == 1) {
						res.data.pdfUrlsName = util.getUrlName(res.data.pdfUrls);
						this.info = res.data;
					}
				});
			},
			// 确认签约
			workSubmit() {
				console.log(111);
				uni.navigateTo({
					url: `/pages/workConfirm/signInfo/signInfo?id=${this.id}&url=${this.info.pdfUrls}`,
				})
			},
			// 预览图片
			previewImg(url) {
				uni.previewImage({
					urls: [url], // 需要预览的图片http链接列表
				})
			},
			// 预览pdf
			previewPdf(item) {
				let url = item.pdfUrls.replace("http:", "https:");
				wx.downloadFile({
					url: url,
					success(res) {
						const filePath = res.tempFilePath
						if (res.statusCode === 200) {
							wx.openDocument({
								filePath: filePath,
								fileType: "pdf",
								success(res) {},
								fail(err) {
									uni.showToast({
										title: JSON.stringify(err),
										icon: 'none',
										duration: 3000
									});
								}
							})
						}
					},
					fail(err) {
						uni.showToast({
							title: JSON.stringify(err),
							icon: 'none',
							duration: 3000
						});
					}
				})
			},
		}
	}
</script>
<style>
	page {
		background-color: #f1f1f1;
	}
</style>
<style lang="scss" scoped>
	.detail {
		.detailInput {
			width: 100%;
			height: 70rpx;
			border: 1px solid #eee;
			padding: 0 20rpx;
			border-radius: 12rpx;
			box-sizing: border-box;
		}

		.detailBtn {
			width: 100%;
			line-height: 88rpx;
			text-align: center;
			background: #EED1A7;
			color: #fff;
			font-size: 28rpx;
			border-radius: 12rpx;
		}
	}
</style>